﻿using System;
using System.Linq;

namespace MinesweeperUtility
{
    class MinesweeperScoreBoard : ScoreBoard
    {
        private int minesLeft;
        private string level;

        public MinesweeperScoreBoard()
            : base()
        {
            this.minesLeft = 100;
            this.level = "Unknown";
        }

        public MinesweeperScoreBoard(string player, string success, string time, int minesLeft, string level)
            : base(player, success, time)
        {
            this.minesLeft = minesLeft;
            this.level = level;
        }

        public override void Draw(int collumnStart, int rowStart)
        {
            Console.BufferHeight += 12;
            Console.WindowHeight += 12;
            Console.SetCursorPosition(collumnStart, rowStart);
            Console.Write("╔");
            Console.Write(new string('═', 18));
            Console.Write("╗");

            Console.SetCursorPosition(collumnStart, Console.BufferHeight - 1);
            Console.Write("╚");
            Console.Write(new string('═', 18));
            Console.Write("╝");

            for (int i = rowStart + 1; i < Console.BufferHeight - 1; i++)
            {
                Console.SetCursorPosition(collumnStart, i);
                if (i == rowStart + 2)
                    Console.Write("║" + "Name: " + this.Player + new string(' ', (12 - this.Player.Length)) + "║");
                else if (i == rowStart + 4)
                    Console.Write("║" + "You " + this.Success + new string(' ', (14 - this.Success.Length)) + "║");
                else if (i == rowStart + 6)
                    Console.Write("║" + "Time: " + this.Time + new string(' ', (12 - this.Time.Length)) + "║");
                else if (i == rowStart + 8)
                    Console.Write("║" + "Mines Left: " + this.minesLeft + new string(' ', (6 - this.minesLeft.ToString().Length)) + "║");
                else if (i == rowStart + 10)
                    Console.Write("║" + "Level:" + this.level + new string(' ', (12 - this.level.Length)) + "║");
                else
                    Console.Write("║" + new string(' ', 18) + "║");
            }
        }
    }
}